| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var assert = require('chai').assert, |
||
| 11 | it('Create with JSON', function(){ |
||
| 12 | var display = GedcomX.DisplayProperties({ |
||
| 13 | "name" : "Joe", |
||
| 14 | "gender" : "Male", |
||
| 15 | "lifespan" : "1900-1956", |
||
| 16 | "birthDate" : "3 March 1900", |
||
| 17 | "birthPlace" : "A place", |
||
| 18 | "deathDate" : "14 January 1956", |
||
| 19 | "deathPlace" : "Another place", |
||
| 20 | "marriageDate" : "9 August 1927", |
||
| 21 | "marriagePlace" : "Marriage place", |
||
| 22 | "ascendancyNumber" : "3", |
||
| 23 | "descendancyNumber" : "6", |
||
| 24 | "familiesAsParent" : [{ |
||
| 25 | "parent1" : { |
||
| 26 | "resource" : "#parent1" |
||
| 27 | }, |
||
| 28 | "parent2" : { |
||
| 29 | "resource" : "#parent2" |
||
| 30 | }, |
||
| 31 | "children" : [ |
||
| 32 | { "resource" : "#child1" }, |
||
| 33 | { "resource" : "#child2" } |
||
| 34 | ] |
||
| 35 | }], |
||
| 36 | "familiesAsChild" : [{ |
||
| 37 | "parent1" : { |
||
| 38 | "resource" : "#parent1" |
||
| 39 | }, |
||
| 40 | "parent2" : { |
||
| 41 | "resource" : "#parent2" |
||
| 42 | }, |
||
| 43 | "children" : [ |
||
| 44 | { "resource" : "#child1" }, |
||
| 45 | { "resource" : "#child2" } |
||
| 46 | ] |
||
| 47 | }] |
||
| 48 | }); |
||
| 49 | assert.equal(display.getName(), 'Joe'); |
||
| 50 | assert.equal(display.getGender(), 'Male'); |
||
| 51 | assert.equal(display.getLifespan(), '1900-1956'); |
||
| 52 | assert.equal(display.getBirthDate(), '3 March 1900'); |
||
| 53 | assert.equal(display.getBirthPlace(), 'A place'); |
||
| 54 | assert.equal(display.getDeathDate(), '14 January 1956'); |
||
| 55 | assert.equal(display.getDeathPlace(), 'Another place'); |
||
| 56 | assert.equal(display.getMarriageDate(), '9 August 1927'); |
||
| 57 | assert.equal(display.getMarriagePlace(), 'Marriage place'); |
||
| 58 | assert.equal(display.getAscendancyNumber(), '3'); |
||
| 59 | assert.equal(display.getDescendancyNumber(), '6'); |
||
| 60 | assert.equal(display.getFamiliesAsParent().length, 1); |
||
| 61 | assert.equal(display.getFamiliesAsChild().length, 1); |
||
| 62 | }); |
||
| 63 | |||
| 163 | }); |